package cn.rdq.iknessplatform.controller;

import cn.rdq.api.dto.CatelogDramaItem;
import cn.rdq.api.po.CatelogDrama;
import cn.rdq.common.CommonResult;
import cn.rdq.iknessplatform.service.CatelogDramaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/catelog-drama")
public class CatelogDramaController {

    @Autowired
    private CatelogDramaService catelogDramaService;

    @GetMapping("/{catelogId}")
    public CommonResult getCatelogDramaInfo(@PathVariable Long catelogId) {
        CatelogDramaItem catelogInfo = catelogDramaService.getCatelogInfo(catelogId);
        return CommonResult.successObj(catelogInfo);
    }

    @PostMapping("/save")
    public CommonResult saveCatelogDramaItem(@RequestBody CatelogDrama catelogDrama) {
        Boolean result = catelogDramaService.addCatelogItem(catelogDrama);
        CommonResult commonResult = new CommonResult();
        if (result) {
            commonResult.setMessage("添加成功");
        } else {
            commonResult.setMessage("添加失败,已存在清单中");
        }
        commonResult.setData(result);
        return commonResult;
    }

}
